import axios from 'axios'

const request = axios.create({
	timeout: 5000
})

// Add a request interceptor
axios.interceptors.request.use(function (config) {
	// Do something before request is sent
	return config;
}, function (error) {
	// Do something with request error
	return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
	// Do something with response data
	return response;
}, function (error) {
	// Do something with response error
	if(error.response.status === 404 )  console.log('资源找不到！！');
	if(error.response.status === 401 )  console.log('缺少token 令牌');
	if(error.response.status === 500 )  console.log('服务器挂了');
	if(error.response.status === 403 )  console.log('权限不够！');
	return Promise.reject(error);
});


export default request